import Layout from '@/layout'
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    hidden: true,
    component: () => import('@/views/login/index'),
    meta: { title: '登录' }
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: '主页', icon: 'home', affix: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    name: 'UserPage',
    meta: {
      title: '用户管理',
      icon: 'users',
      roles: [2, 3]
    },
    children: [
      {
        path: 'student/list',
        component: () => import('@/views/user/student/list'),
        name: 'UserStudentPageList',
        meta: { title: '应聘者列表', noCache: true, roles: [3] }
      },
      {
        path: 'student/edit',
        component: () => import('@/views/user/student/edit'),
        name: 'UserStudentEdit',
        meta: { title: '应聘者编辑', noCache: true, activeMenu: '/user/student/list', roles: [3] },
        hidden: true
      },
      {
        path: 'admin/list',
        component: () => import('@/views/user/admin/list'),
        name: 'UserAdminPageList',
        meta: { title: '管理员列表', noCache: true, roles: [3] }
      },
      {
        path: 'admin/edit',
        component: () => import('@/views/user/admin/edit'),
        name: 'UserAdminEdit',
        meta: { title: '管理员编辑', noCache: true, activeMenu: '/user/admin/list', roles: [3] },
        hidden: true
      },
      {
        path: 'company/list',
        component: () => import('@/views/user/company/list'),
        name: 'UserCompanyPageList',
        meta: { title: '企业用户列表', noCache: true, roles: [2, 3] }
      },
      {
        path: 'company/edit',
        component: () => import('@/views/user/company/edit'),
        name: 'UserCompanyEdit',
        meta: { title: '企业用户编辑', noCache: true, activeMenu: '/user/company/list', roles: [2, 3] },
        hidden: true
      }
    ]
  },
  // 添加以下路由配置到 router.js 的 constantRoutes 数组中

  {
    path: '/forum',
    component: Layout,
    name: 'ForumPage',
    meta: {
      title: '论坛管理',
      icon: 'exam',
      roles: [3]
    },
    alwaysShow: true,
    children: [
      {
        path: 'post/list',
        component: () => import('@/views/forum/post/list'),
        name: 'ForumPostList',
        meta: { title: '帖子列表', noCache: true }
      },
      {
        path: 'post/edit',
        component: () => import('@/views/forum/post/edit'),
        name: 'ForumPostEdit',
        meta: { title: '发布帖子', noCache: true, activeMenu: '/forum/post/list' },
        hidden: true
      },
      {
        path: 'post/view',
        component: () => import('@/views/forum/post/view'),
        name: 'ForumPostView',
        meta: { title: '帖子详情', noCache: true, activeMenu: '/forum/post/list' },
        hidden: true
      }
    ]
  },
  {
    path: '/exam',
    component: Layout,
    name: 'ExamPage',
    meta: {
      title: '测试卷管理',
      icon: 'exam',
      roles: [3]
    },
    children: [
      {
        path: 'paper/list',
        component: () => import('@/views/exam/paper/list'),
        name: 'ExamPaperPageList',
        meta: { title: '测试卷列表', noCache: true }
      },
      {
        path: 'paper/edit',
        component: () => import('@/views/exam/paper/edit'),
        name: 'ExamPaperEdit',
        meta: { title: '测试卷编辑', noCache: true, activeMenu: '/exam/paper/list' },
        hidden: true
      },
      {
        path: 'question/list',
        component: () => import('@/views/exam/question/list'),
        name: 'ExamQuestionPageList',
        meta: { title: '测题列表', noCache: true }
      },
      {
        path: 'question/edit/singleChoice',
        component: () => import('@/views/exam/question/edit/single-choice'),
        name: 'singleChoicePage',
        meta: { title: '测题编辑', noCache: true, activeMenu: '/exam/question/list' },
        hidden: true
      },
      {
        path: 'question/edit/multipleChoice',
        component: () => import('@/views/exam/question/edit/multiple-choice'),
        name: 'multipleChoicePage',
        meta: { title: '多选题编辑', noCache: true, activeMenu: '/exam/question/list' },
        hidden: true
      },
      {
        path: 'question/edit/trueFalse',
        component: () => import('@/views/exam/question/edit/true-false'),
        name: 'trueFalsePage',
        meta: { title: '判断题编辑', noCache: true, activeMenu: '/exam/question/list' },
        hidden: true
      },
      {
        path: 'question/edit/gapFilling',
        component: () => import('@/views/exam/question/edit/gap-filling'),
        name: 'gapFillingPage',
        meta: { title: '填空题编辑', noCache: true, activeMenu: '/exam/question/list' },
        hidden: true
      },
      {
        path: 'question/edit/shortAnswer',
        component: () => import('@/views/exam/question/edit/short-answer'),
        name: 'shortAnswerPage',
        meta: { title: '简答题编辑', noCache: true, activeMenu: '/exam/question/list' },
        hidden: true
      }
    ]
  },
  {
    path: '/task',
    component: Layout,
    name: 'TaskPage',
    meta: {
      title: '测试安排管理',
      icon: 'task',
      roles: [3]
    },
    alwaysShow: true,
    children: [
      {
        path: 'list',
        component: () => import('@/views/task/list'),
        name: 'TaskListPage',
        meta: { title: '测试列表', noCache: true }
      },
      {
        path: 'edit',
        component: () => import('@/views/task/edit'),
        name: 'TaskEditPage',
        meta: { title: '测试创建', noCache: true }
      }
    ]
  },
  {
    path: '/education',
    component: Layout,
    name: 'EducationPage',
    meta: {
      title: '批次管理',
      icon: 'education',
      roles: [4]
    },
    alwaysShow: true,
    children: [
      {
        path: 'subject/list',
        component: () => import('@/views/education/subject/list'),
        name: 'EducationSubjectPage',
        meta: { title: '批次列表', noCache: true }
      },
      {
        path: 'subject/edit',
        component: () => import('@/views/education/subject/edit'),
        name: 'EducationSubjectEditPage',
        meta: { title: '批次编辑', noCache: true, activeMenu: '/education/subject/list' },
        hidden: true
      }
    ]
  },
  {
    path: '/company',
    component: Layout,
    name: 'CompanyPage',
    meta: {
      title: '企业管理',
      icon: 'education',
      roles: [2, 3]
    },
    alwaysShow: true,
    children: [
      {
        path: 'company/list',
        component: () => import('@/views/company/company/list'),
        name: 'CompanyCompanyPage',
        meta: { title: '企业列表', noCache: true, roles: [3] }
      },
      {
        path: 'company/edit',
        component: () => import('@/views/company/company/edit'),
        name: 'CompanyCompanyEditPage',
        meta: { title: '企业编辑', noCache: true, activeMenu: '/company/company/list', roles: [3] },
        hidden: true
      },
      {
        path: 'job/postings',
        component: () => import('@/views/company/job/jobPostingsList'),
        name: 'JobPostingsList',
        meta: { title: '职位发布列表', noCache: true, roles: [2, 3] }
      },
      {
        path: 'job/postings/edit',
        component: () => import('@/views/company/job/jobPostingsEdit'),
        name: 'JobPostingsEdit',
        meta: { title: '职位编辑', noCache: true, activeMenu: '/company/job/postings', roles: [2, 3] },
        hidden: true
      },
      {
        path: 'application/list',
        component: () => import('@/views/company/application/applicationList'),
        name: 'ApplicationList',
        meta: { title: '应聘申请列表', noCache: true, roles: [2, 3] }
      }
    ]
  },

  {
    path: '/advice',
    component: Layout,
    name: 'advicePage',
    meta: {
      title: '意见反馈',
      icon: 'education',
      roles: [3]
    },
    alwaysShow: true,
    children: [
      {
        path: 'advice/list',
        component: () => import('@/views/advice/advice/list'),
        name: 'AdviceAdvicePage',
        meta: { title: '反馈列表', noCache: true }
      }
    ]
  },
  // {
  //   path: '/answer',
  //   component: Layout,
  //   name: 'AnswerPage',
  //   meta: {
  //     title: '成绩管理',
  //     icon: 'answer'
  //   },
  //   alwaysShow: true,
  //   children: [
  //     {
  //       path: 'list',
  //       component: () => import('@/views/answer/list'),
  //       name: 'AnswerPageList',
  //       meta: { title: '答卷列表', noCache: true }
  //     }
  //   ]
  // },
  {
    path: '/message',
    component: Layout,
    name: 'MessagePage',
    meta: {
      title: '消息中心',
      icon: 'message',
      roles: [3]
    },
    alwaysShow: true,
    children: [
      // {
      //   path: 'list',
      //   component: () => import('@/views/message/list'),
      //   name: 'MessageListPage',
      //   meta: { title: '消息列表', noCache: true }
      // },
      {
        path: 'send',
        component: () => import('@/views/message/send'),
        name: 'MessageSendPage',
        meta: { title: '消息发送', noCache: true }
      }
    ]
  },
  // { path: '/student',
  //   redirect:'/student/index.html#/login',
  //   name: 'testMain',
  //   meta: {
  //     title: '心理性格色彩测试中心',
  //     icon: 'education'
  //   },
  // },
  // {
  //   path: '/log',
  //   component: Layout,
  //   name: 'LogPage',
  //   meta: {
  //     title: '日志中心',
  //     icon: 'log'
  //   },
  //   alwaysShow: true,
  //   children: [
  //     {
  //       path: 'user/list',
  //       component: () => import('@/views/log/list'),
  //       name: 'LogUserPage',
  //       meta: { title: '用户日志', noCache: true }
  //     }
  //   ]
  // },
  {
    path: '/profile',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/profile/index'),
        name: 'Profile',
        meta: { title: '个人简介', icon: 'user', noCache: true }
      }
    ]
  },
  { path: '*',
    hidden: true,
    component: () => import('@/views/error-page/404'),
    meta: { title: '404', noCache: true }
  }
]

const router = new Router({
  routes: constantRoutes
})

export {
  constantRoutes,
  router
}
